﻿using System.Windows.Forms;
using System.Data;

namespace Mota.XMLControls
{

    /// <summary>
    /// Represent RichText visual control based on WinForms RichTextBox
    /// </summary>
    public class DXGuiRichText:GuiRichText
    {

        public DXGuiRichText()
        {
            //TODO:Integrate Shurr editor
            visualControl = new RichTextBox();

        }
        /// <summary>
        /// SET| GET RichTextBox Text property
        /// </summary>
        public override string Text
        {
            get
            {
                return (visualControl as RichTextBox).Text;
            }
            set
            {
                (visualControl as RichTextBox).Text = value;
            }
        }
        /// <summary>
        /// Add DataBinding to RichTextBox Text property
        /// </summary>
        /// <param name="valueBinding">main binding source with current record values</param>
        public override void SetValue(object valueBinding)
        {
            if(valueBinding is BindingSource)
                (visualControl as RichTextBox).DataBindings.Add("Text", valueBinding as BindingSource, XmlAttributes["XMLAttribute"], true);
        }

        /// <summary>
        /// Dummy object
        /// </summary>
        public override object Binding
        {
            get
            {
                return null;
            }
            set
            {
               // throw new System.NotImplementedException();
            }
        }

        public override object GetValue()
        {
            return (visualControl as RichTextBox).Text;
        }
    }
}
